
local time = achievements.GetValue( "Loner", "total", 0 )

local target = 3600
local radius = 4096
local function Update()
	// There are no other players.
	if ( #player.GetAll() == 1 ) then return end
	
	local ply = LocalPlayer()
	if ( !ValidEntity( ply ) ) then return end
	
	if ( time != target ) then
		local find = ents.FindInSphere( ply:GetPos(), radius )
		for _, e in pairs( find ) do if ( e:IsPlayer() && e != ply ) then return end end
		
		time = math.Clamp( time + 1, 0, target )
		
		achievements.SetValue( "Loner", "total", time )
		achievements.Update( "Loner", time / target, achievements.FormatTime( time, "h:m:s" ) )
		
		if ( time >= target ) then
			timer.Destroy( "Achievements.Loner" )
		end
	end
end
timer.Create( "Achievements.Loner", 1, 0, Update )

achievements.Register( "Loner", "Spend a total of one hour away from other players.", "achievements/loner", time / target, achievements.FormatTime( time, "h:m:s" ) )